<div class="main-content">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <a href="{:U('Admin/Index/index')}">后台首页</a>
            </li>
            <php>
                $path = S('ADMIN_MENU_PATH');
                for ($i = count($path); $i >= 0; $i--) {
                    if ($path[$i][id] > 0) {
                        echo '<li><a href="'.U($path[$i][name]).'">'.$path[$i][title].'</a></li>';
                    }
                }
                echo '<li>'.S('ADMIN_MENU_ACTION')['title'].'</li>';
            </php>
        </ul><!-- /.breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="ace-icon fa fa-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- /.nav-search -->
        <div class="page-header page-header-background">
            <div class="row">
                <div class="col-xs-12">
                    <div class="col-xs-2">
                        <p>
                            <button class="btn btn-white btn-info btn-bold" data-toggle="modal" href="{:U('Admin/Category/addCate')}" data-target="#myModal" class="rule-edit" data-rel="tooltip" title="添加"><i class="ace-icon fa fa-plus-circle bigger-130 blue"></i>添加</button>
                        </p>
                    </div>
                </div>
            </div>
        </div><!--1 page-header end-->
    </div>
    <div class="page-content ">
        <div class="page-content-area">
            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <div class="row">
                        <div class="col-sm-8">
                            <div class="dd" id="nestable">
                                <ol class="dd-list">
                                <li class="dd-item" data-id="0">
                                    <div class="dd-handle">
                                        商品分类管理
                                        <div class="pull-right action-buttons">
                                            <a class="green" data-toggle="modal" href="{:U('Admin/Category/addCate')}" data-target="#myModal">
                                                <i class="ace-icon fa fa-plus-circle bigger-130"></i>
                                            </a>
                                        </div>
                                    </div>
                                <if condition="!empty($cateRow)">

                                <php>
                                function showT($data) {
                                    echo '<ol class="dd-list">';
                                    foreach ($data as $key => $val) {
                                        echo '<li class="dd-item item-orange " data-id="'.$val[cate_id].'">';

                                        echo '<div class="dd-handle">'.$val['cate_name'];
                                        echo '<div class="pull-right action-buttons dd-nodrag">';
                                        echo '<a class="green" data-toggle="modal" href="'.U('Admin/Category/addCate/?parent='.$val[cate_id]).'" data-target="#myModal">';
                                        echo '<i class="ace-icon fa fa-plus-circle bigger-130" title="添加"></i></a>';
                                        echo '<a class="blue" data-toggle="modal" href="'.U('Admin/Category/editCate/?cateid='.$val[cate_id]).'" data-target="#myModal"><i class="ace-icon fa fa-pencil bigger-130"  title="修改"></i></a>';
                                        if (empty($val['childs'])) {
                                            echo '<a class="red" data-toggle="modal" href="'.U('Admin/Category/delCate/?cateid='.$val[cate_id]).'" data-target="#delModal"　title="删除"><i class="ace-icon fa fa-trash-o bigger-130" title="删除"></i></a>';
                                        }
                                        echo '</div></div>';
                                        if (!empty($val['childs'])) {
                                            showT($val['childs']);
                                        }

                                        echo '</li>';
                                    }
                                    echo '</ol>';
                                }
                                showT($cateRow);
                                </php>

                                </if>
                                </li>
                                </ol>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content" id="modal-content">

        </div>
      </div>
    </div>
    <!-- small Modal -->
    <div class="modal fade .bs-example-modal-sm" id="delModal" tabindex="-1" role="dialog" aria-labelledby="delModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">

        </div>
      </div>
    </div>
</div>
<script type="text/javascript">
    jQuery(function($){
        $('#nestable').nestable();
        $('.dd-handle a').on('mousedown', function(e){
            e.stopPropagation();
        });
        $('#myModal').on('hidden.bs.modal', function(){
           $('#myModal').removeData('bs.modal');
        });
        $('#delModal').on('hidden.bs.modal', function(){
           $('#delModal').removeData('bs.modal');
        });

        $('[data-target="#delModal"]').on('click', function() {
            $.get($(this).prop('href'), function(html) {
                $('#myModal > #modal-content').html(html);
            });

        });
    });

</script>
